<template>
  <h2>当前求和为:{{ sum }}</h2>
  <button @click="sum++">点我+1</button>
</template>

<script>
import { onBeforeUnmount, onUnmounted, ref } from "vue";
export default {
  name: "Demo",
  setup() {
    let sum = ref(0);

    onBeforeUnmount(() => {
      console.log("Demo---onBeforeUnmount");
    });
    onUnmounted(() => {
      console.log("Demo---onUnmounted");
    });

    return {
      sum,
    };
  },
};
</script>

<style></style>
